package edu.fiu.cis.personalize.server.berkDB.serializers;

import java.util.Set;

import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

import edu.fiu.cis.personalize.server.graph.Group;
import edu.fiu.cis.personalize.server.graph.store.NodeEdges;

public class GroupSerializer extends NodeSerializer<Group> {

	private IntegerSetSerializer sel = new IntegerSetSerializer();

	@Override
	public void objectToEntry(Group node, TupleOutput to) {
		super.objectToEntry(node, to);
		sel.objectToEntry(node.getMembers(), to);
		to.writeString(node.getDescription());
	}

	@Override
	protected Group process(TupleInput ti,int id, String gname, NodeEdges nodeEdges,
			double rank) {
		Set<Integer> membersSet = sel.entryToObject(ti);
		String description = ti.readString();
		
		return Group.create(id, gname, nodeEdges, rank,membersSet,description);
	}

}
